﻿//
// Created by Administrator on 2020/9/13.
//

#ifndef EXAMPLE_CPP_STACKTEMPLATE_H
#define EXAMPLE_CPP_STACKTEMPLATE_H

#include <iostream>

template<typename Item, int SIZE>
class StackTemplate {
private:
    Item itemArr[SIZE];
    int index{};
public:
    void push(Item item);

    Item pop();

    bool isEmpty();

    bool isFull();

    StackTemplate();

    StackTemplate(int maxSize);
};


template<typename Item, int size>
StackTemplate<Item, size>::StackTemplate() {

}

template<typename Item, int size>
StackTemplate<Item, size>::StackTemplate(int maxSize) {
    std::cout << "maxSize:" << maxSize << std::endl;
}

template<typename Item, int size>
bool StackTemplate<Item, size>::isFull() {
    return this->index == size;
}


template<typename Item, int size>
bool StackTemplate<Item, size>::isEmpty() {
    return this->index == 0;
}


template<typename Item, int size>
Item StackTemplate<Item, size>::pop() {
    Item result = this->itemArr[this->index];
    this->index--;
    return result;
}

template<typename Item, int size>
void StackTemplate<Item, size>::push(Item item) {
    this->itemArr[this->index] = item;
    this->index++;
}


#endif //EXAMPLE_CPP_STACKTEMPLATE_H
